#!/user/bin/env node

const fs = require('fs');
const path = require('path');
const inquirer = require('inquirer');
const ejs = require('ejs');

inquirer.prompt([
  {
    type: 'input',
    name: 'name',
    message: 'You Project Name？'
  }
]).then(anwsers => {
  const tplDir = path.join(__dirname, 'template');
  const destDir = process.cwd();

  fs.readdir(tplDir, (err, file) => {
    if (err) throw err;
    file.forEach(i => {
      const souceDir = path.join(tplDir, i);
      const targetDir = path.join(destDir, i);
      ejs.renderFile(fileDir, anwsers, (err, res) => {
        if (err) throw err;
        fs.writeFileSync(targetDir, res);
      });
    });
  });
})